<?php
	$root = $_SERVER['DOCUMENT_ROOT'];
	include($root . "/util/session.php");//checks that the user is logged in
	include($root . "/util/privilege_check.php");
	checkPrivilege("admin");
	$query = "SELECT * FROM degrees";
	$result = mysqli_query($db,$query);
	if(mysqli_num_rows($result) < 1){
		header("Location: /admin/admin.php?msg=No Degrees");
	}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<title>Degree List</title>
  	<link rel="stylesheet" type="text/css" href="adminStyle.css">
  	<link rel="stylesheet" type="text/css" href="tableStyle.css">
</head>

<body>
  	<?php
  	include($root . "/admin/header.php");
	?>
	<li><a href="/admin/admin.php">Back</a></li>
	<table border="1px" id="users">
		<thead>
			<tr>
				<th>Actions</th>
				<th>DegreeID</th>
				<th>Name</th>
				<th>Description</th>
			</tr>
		</thead>
		<tbody>
			<?php //ugly php + html hybrid code that does stuff
				while($row=mysqli_fetch_assoc($result)){?>
				<tr>
					<td>
						<a href="/admin/degreeMod.php?degreeID=<?php echo $row['degreeID']?>">Modify</a>
						<a href="/admin/subjectList.php?degreeID=<?php echo $row['degreeID']?>">List Subjects</a>
						<a href="/admin/subjectAdd.php?degreeID=<?php echo $row['degreeID']?>">Add a subject</a>
						<a href="/admin/degreeDel.php?degreeID=<?php echo $row['degreeID']?>">Delete</a>
					</td>
					<td><?php echo $row['degreeID']; ?>
					</td>
					<td><?php echo $row['degreeName']; ?></td>
					<td><?php echo $row['description']; ?></td>
				</tr>
			<?php }?>
		</tbody>
	</table>
	<?php
  	include($root . "/admin/footer.php");
	?>
</body>
</html>

